﻿$(function () {
    var $container = $('#isotope');
    var $cityFilter = $('#city-filter');

    //$dropdown = $(".ddl").kendoDropDownList();

    $container.isotope({
        itemSelector: '.item',
        getSortData: {
            viewed: function ($elem) {
                return $elem.find('.last-viewed').text();
            },
            updated: function ($elem) {
                return $elem.find('.last-updated').text();
            },
            created: function ($elem) {
                return $elem.find('.created').text();
            }
        },
        sortAscending: false
    });

    $('#sort-by a').click(function () {
        // get href attribute, minus the '#'
        var sortName = $(this).attr('href').slice(1);

        $('#sort-by a').removeClass('label');
        $(this).addClass('label');

        $container.isotope({ sortBy: sortName });
        return false;
    });

    $('#filters a').click(function () {
        var selector = $(this).data('filter');
        $container.isotope({ filter: selector });

        $('#filters a').removeClass('label');
        $(this).addClass('label');
        return false;
    });

    $('#city-filter').change(function () {
        var selector = $(this).val();

        if ($('#isotope .item').hasClass('match')) {
            selector += ".match";
        }

        $container.isotope({ filter: selector });
        return false;
    });
});